// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
// import vueResource from 'vue-resource'
// import axios from 'axios';
import store from './store';
import Mint from 'mint-ui';
import 'mint-ui/lib/style.css';

import './assets/css/common.scss'
import './assets/css/components.scss'

//消除点击延时
import FastClick from 'fastclick'

FastClick.attach(document.body);

import axios from 'axios'

Vue.prototype.$ajax = axios;

Vue.use(Mint);
Vue.config.productionTip = false
// Vue.use(vueResource)
// Vue.http.options.emulateJSON = true;


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: {App}
})

let indexScrollTop = 0;
router.beforeEach((route, redirect, next) => {
  if (route.path !== '/') {
    indexScrollTop = document.body.scrollTop;
  }
  document.title = route.meta.title || document.title;
  next();
});

router.afterEach(route => {
  if (route.path !== '/') {
    document.body.scrollTop = 0;
  } else {
    Vue.nextTick(() => {
      document.body.scrollTop = indexScrollTop;
    });
  }
});
